package com.hqyj.controller;

import com.hqyj.dao.InfoDao;
import com.hqyj.entity.Info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Date;

@Controller
@RequestMapping("/info")
public class InfoController {
    @Autowired
    InfoDao infoDao;
    @GetMapping
    @RequestMapping(value = "/addInfo")
    String add() {
        return "restful/addInfo";
    }

    @RequestMapping(value = "/addInfo",method = RequestMethod.POST)
    String addInfo(Model model, String infoname, Date infodate, String infocontant, String infostate, Integer user_id){
        Date date = new Date();
//        Info info=new Info("请假",date,"请假","1",2);
//        System.out.println("info是"+info);
        int i = infoDao.insertInfo(infoname,date,infocontant,"1",2);
        if (i>0){
            return "restful/addInfo";
        }else
            System.out.println("发送失败！！！");
        return "restful/addInfo";
    }
}
